package br.com.commons.utility.message;

import java.util.List;

public class Message {

	private TypeMessage type;
	private String message;
	private List<Message> messages;
	
	public Message() { }
	
	public Message(TypeMessage type, String message) {
		this.type = type;
		this.message = message;
	}
	
	public TypeMessage getType() {
		return type;
	}
	public void setType(TypeMessage type) {
		this.type = type;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}	
	public List<Message> getMessages() {
		return messages;
	}
	public void setMessages(List<Message> messages) {
		this.messages = messages;
	}

	private Message getSuccesMessage(String message){
		return new Message(TypeMessage.SUCCES, message);		
	}	
	private Message getInformationMessage(String message){
		return new Message(TypeMessage.INFORMATION, message);		
	}	
	private Message getWarningMessage(String message){
		return new Message(TypeMessage.WARNING, message);		
	}	
	private Message getErrorMessage(String message){
		return new Message(TypeMessage.ERROR, message);		
	}
	
	public void addMessage(Message message){
		messages.add(message);
	}
	public void addMessageSucces(String message){
		messages.add(getSuccesMessage(message));
	}
	public void addMessageInformation(String message){
		messages.add(getInformationMessage(message));
	}
	public void addMessageWarning(String message){
		messages.add(getWarningMessage(message));
	}
	public void addMessageError(String message){
		messages.add(getErrorMessage(message));
	}
}
